next up previous contents index
Next: forward defined functions Up: Using functions and procedures Previous: Parameter lists

Function overloading

Function overloading simply means that you can define the same function more than once, but each time with a different formal parameter list. The parameter lists must differ at least in one of it's elements type.

When the compiler encounters a function call, it will look at the function parameters to decide which od the defined function This can be useful if you want to define the same function for different types. For example, if the RTL, the Dec procedure is is defined as:
listing4187
When the compiler encounters a call to the dec function, it wil first search which function it should use. It therefore checks the parameters in your function call, and looks if there is a function definition which maches the specified parameter list. If the compiler finds such a function, a call is inserted to that function. If no such function is found, a compiler error is generated.

You cannot have overloaded functions that have a cdecl or export modifier (Technically, because these two modifiers prevent the mangling of the function name by the compiler)


next up previous contents index
Next: forward defined functions Up: Using functions and procedures Previous: Parameter lists

Michael Van Canneyt
Fri Sep 25 09:15:40 MEST 1998